package com.xybbs.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageInfo;
import com.xybbs.entity.Tips;
import com.xybbs.service.TipsService;

@RequestMapping("main")
@Controller

public class MainController {
	@Autowired
	TipsService tipsService;
	
	@RequestMapping("toMainPage.do")
	public String toMainPage(HttpServletRequest req,@RequestParam(defaultValue="1")String pageNum,@RequestParam(defaultValue="5")String pageSize) {
		PageInfo<Tips> list = tipsService.checkAllWithUserByPage(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
		req.setAttribute("tips", list.getList());
		req.setAttribute("pageNum", list.getPageNum());
		req.setAttribute("pageSize", list.getPageSize());
		req.setAttribute("pages", list.getPages());
		req.setAttribute("total", list.getTotal());
		return "main"; 
	}
}
